Contents | Index | < Browse | Browse >

LETTERstrtolULETTER Converts a string to a long integer.

Übrsicht
#include <stdlib.h>

r = strtol(s,nextchar,base);

long int r;
const char *s;
char **nextchar;
int base;

Portability
ANSI

Description
This function converts a string "s" into a long integer value according to the specified base. "nextchar" can be NULL or a pointer to a variable which points to the first character in the string which should not be converted.

"base" may range from 2 to 36. Valid digit characters are "0" to "9" and the letters from "a" to "z" and "A" to "Z". The highest allowed digit depends on the base chosen.

If the base is zero, the base will be determined out of the string itself: if it begins with "0" the number is octal (base 8), if it begins with "0x" or "0X" it is hexadecimal (base 16), in all other cases it is decimal.

Returns
The converted, signed number.

See also
atoi , sscanf